import { Component } from '@angular/core';
import { NavController, ModalController, NavParams, ViewController, PopoverController} from 'ionic-angular';
import { CartPage } from '../cart/cart';
import { PopoverPage } from './comm-detail-popover';

@Component({
  selector: 'page-comm-detail',
  templateUrl: 'comm-detail.html'
})
export class CommDetailPage {
  params: Object;
  pushPage: any;
  segmentsArray = ['comm', 'detail', 'comments'];
  segment:string = this.segmentsArray[0];

  constructor(public navCtrl: NavController, public modalCtrl: ModalController, public viewCtrl: ViewController, public popoverCtrl: PopoverController) {
    this.pushPage=CartPage;
    this.params= {id: 1};
  }
  isOutline: boolean = false;
  slides = [
  ];

  goCart(){
    this.navCtrl.push(CartPage);
  }

  dismiss() {
   this.viewCtrl.dismiss();
 }

 swipeEvent(event){
   // left
   if(event.direction==2){
      if(this.segmentsArray.indexOf(this.segment)<2){
        this.segment = this.segmentsArray[this.segmentsArray.indexOf(this.segment)+1];
      }
   }
   // right
   if(event.direction==4){
     if(this.segmentsArray.indexOf(this.segment)>0){
       this.segment = this.segmentsArray[this.segmentsArray.indexOf(this.segment)-1];
  }
}
 }

 presentPopOver(myEvent){
   let popover = this.popoverCtrl.create(PopoverPage);
   popover.present(
     {ev:myEvent}
   );
 }

}
